package vistop.datatypes;

import java.util.ArrayList;
import java.util.List;

public class Face extends GeometricalObject{
	private List<Directed<Edge>> edges;
	
	public Face(int id) {
		super(id);
		this.edges = new ArrayList<Directed<Edge>>();
	}
	
	public Face(int id, List<Directed<Edge>> edges) {
		super(id);
		this.edges = edges;
	}
	
	public void addEdge(Edge e, int direction) {
		Directed<Edge> de = new Directed<Edge>(e, direction);
		edges.add(de);
		//System.out.println("Adding edge " + e.toString() + 
				//" to face ID=" + super.getId());
	}
		
	public List<Directed<Edge>> getEdges() {
		return this.edges;
	}

	public Polygon getPolygons() {
		//return new Polygon(this.edges);
		// TODO
		return null;
	}
		
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((edges == null) ? 0 : edges.hashCode());
		result = prime * result + super.getId();
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Face other = (Face) obj;
		if (edges == null) {
			if (other.edges != null)
				return false;
		} else if (!edges.equals(other.edges))
			return false;
		if (super.getId() != other.getId())
			return false;
		return true;
	}
	
	public String toString() {
		String str = "FACE ID=" + super.getId() +": {";
		for (Directed<Edge> de : edges) {
			str += de.getDirection() + " * " 
					+ de.getGeometricalObject().toString() + "\n";
		}
		return str + "}Face"+super.getId()+"End\n";
	}
	
}
